package socket.client;


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;

public class ReceiveMessage implements Runnable {
    private Socket socket;

    public ReceiveMessage(Socket socket) {
        this.socket = socket;
    }

    @Override
    public void run() {
        try {
            //获取输入流，接收数据
            BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            while (true) {
                String message = reader.readLine();
                System.out.println("收到消息：" + message);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}